﻿using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.Test.Host.Web;

public class TestServerHttpClientFactory(IServiceProvider serviceProvider) : ITestServerHttpClientFactory
{
    private readonly IServiceProvider _serviceProvider = serviceProvider;

    public HttpClient GetTestClient()
    {
        var testServer = (TestServer)_serviceProvider.GetRequiredService<IServer>();
        return testServer.CreateClient();
    }
}
